$(function() {
	// 控制各个面板显示和隐藏
	$('#tab li').click(function() {
		var i = $(this).index();
		$('#tab li').removeClass('fli').eq(i).addClass('fli');
		$('#tab_con > div').removeClass('fdiv').eq(i).addClass('fdiv');
	});
	// --------------------------收支记录
	$('#mmtab a').click(function() {// 一月 三月
		var i = $(this).index();
		$('#mmtab a').removeClass('current').eq(i).addClass('current');
		$("#mmonth").val(i);
		to_find(1, 'moneyRecordPage');
	});
	$('#mmgttab a').click(function() {// 资金流向
		var i = $(this).index();
		$('#mmgttab a').removeClass('current').eq(i).addClass('current');
		$("#mmoneyGoto").val(i);
		to_find(1, 'moneyRecordPage');
	});
	$('#mrstab a').click(function() {// 交易状态
		var i = $(this).index();
		$('#mrstab a').removeClass('current').eq(i).addClass('current');
		$("#mrechargeStatus").val(i);
		to_find(1, 'moneyRecordPage');
	});
	$('#mrttab a').click(function() {// 交易分类
		var i = $(this).index();
		$('#mrttab a').removeClass('current').eq(i).addClass('current');
		$("#mrechargeType").val((this).id);
		to_find(1, 'moneyRecordPage');
	});

	// -----------------------------充值记录
	$('#rmtab a').click(function() {// //一月 三月
		var i = $(this).index();
		$('#rmtab a').removeClass('current').eq(i).addClass('current');
		$("#rmonth").val(i);
		to_find(1, 'RechargeRecordPage');
	});
	$('#rrstab a').click(
	// 交易状态
	function() {
		var i = $(this).index();
		$('#rrstab a').removeClass('current').eq(i).addClass('current');
		$("#rrechargeStatus").val((this.id).substring(2,(this.id).length));//eg:id="re1"
		to_find(1, 'RechargeRecordPage');
	});

	// -----------------------------提现记录
	$('#wmtab a').click(function() {// 一月 三月
		var i = $(this).index();
		$('#wmtab a').removeClass('current').eq(i).addClass('current');
		$("#wmonth").val(i);
		to_find(1, 'withdrawPage');
	});
	$('#wrstab a').click(
	// 交易状态
	function() {
		var i = $(this).index();
		$('#wrstab a').removeClass('current').eq(i).addClass('current');
		$("#wrechargeStatus").val(i);
		to_find(1, 'withdrawPage');
	});
	
	// -----------------------------钱包收益
	$('#qbEarningsPagetab a').click(function() {// 一月 三月
		var i = $(this).index();
		$('#qbEarningsPagetab a').removeClass('current').eq(i).addClass('current');
		$("#qbMonth").val($(this).attr("propertyId"));
		
		$("#qblowTime").val("");
		$("#qbTopTime").val("");
		
		to_find(1, 'qbEarningsPage');
	});
	
	//-------------------------------定期计划收益
	$('#hkbEarningsPagetab a').click(function() {// 一月 三月......
		var i = $(this).index();
		$('#hkbEarningsPagetab a').removeClass('current').eq(i).addClass('current');
		$("#hbkMonth").val($(this).attr("propertyId"));
		
		$("#hkblowTime").val("");
		$("#hkbTopTime").val("");
		
		to_find(1, 'hkbEarningsPage');
	});
	$('#hkbEarningsPagetabJH a').click(function() {//  1月定期， 2月定期......
		var i = $(this).index();
		$('#hkbEarningsPagetabJH a').removeClass('current').eq(i).addClass('current');
		$("#hkbProjectDefId").val($(this).attr("propertyId"));
		to_find(1, 'hkbEarningsPage');
	});
});

// 输入时间验证
function checkTimeVal(str) {
	var idlstr = "";
	var idtstr = "";
	if (str == "moneyRecordPage") { 
		idlstr = "mlowTime";
		idtstr = "mtopTime";
	} else if (str == 'RechargeRecordPage') {
		idlstr = "rlowTime";
		idtstr = "rtopTime";
	} else if (str == 'withdrawPage') {
		idlstr = "wlowTime";
		idtstr = "wtopTime";
	} else if (str == 'qbEarningsPage') {
		idlstr = "qblowTime";
		idtstr = "qbTopTime";
	} else if (str == 'hkbEarningsPage') {
		idlstr = "hkblowTime";
		idtstr = "hkbTopTime";
	}
	
	var lowTime = $('#' + idlstr).val();
	var topTime = $('#' + idtstr).val();
	if (lowTime != '' && topTime != '') {
		if (new Date(Date.parse(lowTime.replace(/-/g, "/"))) > new Date(Date
				.parse(topTime.replace(/-/g, "/")))) {
			layer.alert("起始时间必须早于结束时间！");
			$('#' + idtstr).val(null);
			return false;
		} else if (lowTime != ''
				&& new Date(Date.parse(lowTime.replace(/-/g, "/"))) >= new Date()) {
			layer.alert("起始日期不可为未来时间！");
			$('#' + idlstr).val(null);
			return false;
		} else if (topTime != ''
				&& new Date(Date.parse(topTime.replace(/-/g, "/"))) > new Date()) {
			layer.alert("最后日期不可为未来时间！");
			$('#' + idtstr).val(null);
			return false;
		}
	}
}

// 点击各个模块异步加载查询
function to_find(pagenum, str) {
	var vals = checkTimeVal(str);// 输入时间验证
	if (vals == false) {
		return;
	}
	var datastr = getdataStr(str, pagenum);// 根据不同模块获得不同查询参数	
	
	var ii = layer.load('加载中...');
	$.ajax({
		type : "POST",
		url : "fundRecord_" + str + ".action",
		data : datastr,
		dataType : 'json',
		success : function(data) {
			layer.close(ii);//关闭加载层
			var table = $("#" + str + "_tab  tbody");
			table.empty();// 清空数据显示部分
			$("#" + str + "_page").empty();// 清空分页部分
			var json = data[0].records; // 取得page里面的records集合
			
			//如果是钱包收益，赋值daysInYear变量，作为计算年化收益
			if (str == "qbEarningsPage") {
				$("#daysInYear").val((data[0].params == null) ? "" : data[0].params.daysInYear);
				$("#qbCash").html((data[0].params == null) ? 0 : milliFormat(tomyToFixed(data[0].params.qbCash + "")));
				$("#qbTotalCash").html(milliFormat(tomyToFixed(data[0].someStr + "")));
			}
			
			//如果是钱包收益，赋值daysInYear变量，作为计算年化收益
			if (str == "hkbEarningsPage") {
				$("#hkbDaysInYear").val((data[0].params == null) ? "" : data[0].params.daysInYear);
				$("#hkbTotalCash").html(milliFormat(tomyToFixed(data[0].someStr + "")));
			}
			
			var htmlstr = "";
			if (json == undefined || json == "") {// 没有数据时候
				htmlstr = '<tr  height="42">';
				if(str=="withdrawPage"){
					htmlstr += '<td align="center" colspan="8">暂无数据</td>';
				}else if(str=="qbEarningsPage"){
					htmlstr += '<td align="center" colspan="5">暂无数据</td>';
				}else{
					htmlstr += '<td align="center" colspan="6">暂无数据</td>';
				}
				htmlstr += '</tr>';
			} else {
				htmlstr = showHtml(str, json, htmlstr);
			}
			
			table.append(htmlstr);// 数据显示部分
			var totalpage = data[0].totalPage;// 总页数
			var pagenum = data[0].currentPage;// 当前页
			var sumstr = data[0].someStr;//总计/余额部分
			showSum(str, sumstr);// 显示总计部分
			if (json != undefined && json != "") {
				$("#" + str + "_page").append(linkedPage(totalpage, pagenum, str));// 分页部分
			}
		}
	});
}

//
function to_findfromIndex(pagenum, str){
	var i;
	if(str=="moneyRecordPage"){
		i=0;
	}else if(str=="RechargeRecordPage"){
		i=1;
	}else if(str=="withdrawPage"){
		i=2;
	}
	$('#tab li').removeClass('fli').eq(i).addClass('fli');
	$('#tab_con > div').removeClass('fdiv').eq(i).addClass('fdiv');
	to_find(pagenum,str);
}

// 显示总计部分
function showSum(str, val) {
	if (str == "moneyRecordPage") {
		//val = val.split(";");
		/*$("#minsum").empty();//  
		$("#moutsum").empty();//  
		$("#mcash").empty();//  
		$("#minsum").text(val[0]);// 进账
		$("#moutsum").text(val[1]);// 出账
		$("#mcash").text(val[2]);// 可用余额*/
		//document.getElementById("minsum").innerHTML=tomyToFixed(val[0]+"");
		//document.getElementById("moutsum").innerHTML=tomyToFixed(val[1]+"");
		document.getElementById("mcash").innerHTML=milliFormat(tomyToFixed(val));
	} else if (str == 'RechargeRecordPage') {
		//val = val.split(";");
		/*$("#rsum").empty();//  
		$("#rcash").empty();//  
		$("#rsum").text(val[0]);
		$("#rcash").text(val[1]);*/
		//document.getElementById("rsum").innerHTML=tomyToFixed(val[0]+"");
		document.getElementById("rcash").innerHTML=milliFormat(tomyToFixed(val));
	} else if (str == 'withdrawPage') {
		//val = val.split(";");
		/*$("#wsum").empty();//  
		$("#wcash").empty();// 
		$("#wsum").text(val[0]);
		$("#wcash").text(val[1]);*/
		//document.getElementById("wsum").innerHTML=tomyToFixed(val[0]+"");
		document.getElementById("wcash").innerHTML=milliFormat(tomyToFixed(val));
	}
}

// 根据不同模块获得不同查询参数字符
function getdataStr(strType, currentPage) {
	var datastr = "";
	if (strType == "moneyRecordPage") {
		var m = trim($("#mmonth").val());// 一月
		var lt = trim($("#mlowTime").val());// 开始时间
		var tt = trim($("#mtopTime").val());// 结束时间
		var mrs = trim($("#mrechargeStatus").val());// 交易状态
		var mrt = trim($("#mrechargeType").val());// 交易分类
		var mgt = trim($("#mmoneyGoto").val());// 资金流向
		datastr = {
			"qupa.plateType" : mrt,
			"qupa.money_goto" : mgt,
			"qupa.toptime" : tt,
			"qupa.lowtime" : lt,
			"qupa.monthType" : m,
			"qupa.status" : mrs,
			"currentPage" : currentPage
		};
	} else if (strType == "RechargeRecordPage") {
		var m = trim($("#rmonth").val());// 一月
		var lt = trim($("#rlowTime").val());// 开始时间
		var tt = trim($("#rtopTime").val());// 结束时间
		var mrs = trim($("#rrechargeStatus").val());// 交易状态
		datastr = {
			"qupa.toptime" : tt,
			"qupa.lowtime" : lt,
			"qupa.monthType" : m,
			"qupa.status" : mrs,
			"currentPage" : currentPage
		};
	} else if (strType == "withdrawPage") {
		var m = trim($("#wmonth").val());// 一月
		var lt = trim($("#wlowTime").val());// 开始时间
		var tt = trim($("#wtopTime").val());// 结束时间
		var mrs = trim($("#wrechargeStatus").val());// 交易状态
		datastr = {
			"qupa.toptime" : tt,	
			"qupa.lowtime" : lt,
			"qupa.monthType" : m,
			"qupa.status" : mrs,
			"currentPage" : currentPage
		};
	} else if (strType == "qbEarningsPage") {		
		var lt = trim($("#qblowTime").val());// 开始时间
		var tt = trim($("#qbTopTime").val());// 结束时间
		if (lt != "" || tt != "") {
			$("#qbMonth").val("");
			$('#qbEarningsPagetab a').removeClass('current').eq(0).addClass('current');
		}
		var m = trim($("#qbMonth").val());// 一月		
		datastr = {
			"qupa.toptime" : tt,	
			"qupa.lowtime" : lt,
			"qupa.monthType" : m,
			"qupa.status" : mrs,
			"currentPage" : currentPage
		};
	} else if (strType == "hkbEarningsPage") {
		var lt = trim($("#hkblowTime").val());// 开始时间
		var tt = trim($("#hkbTopTime").val());// 结束时间
		if (lt != "" || tt != "") {
			$("#hbkMonth").val("");
			$('#hkbEarningsPagetab a').removeClass('current').eq(0).addClass('current');
		}
		var m = trim($("#hbkMonth").val());// 一月
		var hkbProjectDefId = trim($("#hkbProjectDefId").val());// hkbProjectDefId
		datastr = {
			"qupa.toptime" : tt,	
			"qupa.lowtime" : lt,
			"qupa.monthType" : m,
			"qupa.status" : mrs,
			"currentPage" : currentPage,
			"qupa.hkbProjectDefId" : hkbProjectDefId
		};
	}
	return datastr;
}

$(document).ready(function() {	
	$('.money_detail').hover(function() {
		$('div', this).slideDown(200);
		$(this).children('a:first').addClass("hov");
	}, function() {
		$('div', this).slideUp(100);
		$(this).children('a:first').removeClass("hov");		
	});
});

// 数据动态显示部分
function showHtml(strType, json, htmlstr) {
	if (strType == "moneyRecordPage") {// 收支记录模块
		$.each(json,
		function(i, v) {
			var newAmount=tomyToFixed((v.amount)+"");//截取小数点后两位 不用四舍五入
			if(i%2!=0){ 
			    htmlstr += '<tr bgcolor="#f5f5f5" >';
			}else{
				htmlstr += '<tr>';
			}
			htmlstr += '<td align="center">' + showRecordTime(v.recordTime)+ '</td>';
			htmlstr += '<td align="left" title="'+getMangerGoods(v.orderId,v.moneyType,v.oppositeTradeName)+'">' + get_moneyTypeName(v.moneyType,v.info,v.oppositePlateformName,v.oppositeTradeName,v.remarkSomeinfo,v.moneyTypeCell,v.moneyTypeName,v.moneyTypeCellName)+ "&nbsp;&nbsp;<br>" + v.orderId + '</td>';
			htmlstr += '<td align="left">&nbsp;&nbsp;&nbsp;&nbsp;'+ get_otherPlate(v.moneyType,v.oppositePlateformName,v.oppositeTradeName)+'</td>';
			htmlstr += styleShowAmount(v.moneyType,newAmount,v.orderId)+ ' </td>';
			htmlstr += get_moneyRecordStatus(v.status,v.moneyType);// 资金记录状态判断
			htmlstr += '<td align="center"><a href="javascript:void(0)" class="blue" onclick="to_detail(\''+ v.moneyType + '\',\''+ v.orderId + '\',\''+ get_moneyTypeName(v.moneyType,v.info,v.oppositePlateformName,v.oppositeTradeName,v.remarkSomeinfo,v.moneyTypeCell,v.moneyTypeName,v.moneyTypeCellName) + '\',\''+get_otherPlate(v.moneyType,v.oppositePlateformName,v.oppositeTradeName)+'\')">查看</a></td>';
			htmlstr += '</tr>';   
		});
	} else if (strType == "RechargeRecordPage") {// 充值记录
		$.each(json, function(i, v) {
			var amount=tomyToFixed((v.applyAmount)+"");//截取小数点后两位 不用四舍五入
			if(i%2!=0){ 
			    htmlstr += '<tr bgcolor="#f5f5f5" >';
			}else{
				htmlstr += '<tr>';
			}
			var moneyfrom = get_moneyfrom(v.rechargeType);
			htmlstr += '<td align="center">' + v.orderNo + '</td>';
			htmlstr += '<td align="center">' + v.appleTime + '</td>';
			htmlstr += '<td align="center">在线充值</td>';
			htmlstr += '<td align="center">收入</td>';
			htmlstr += '<td align="left" >' + ShowRechargeMoney(amount) + "&nbsp;&nbsp;"+ moneyfrom + '</td>';
			htmlstr += get_RechargeRecordStatus(v.status);// 充值状态判断
			htmlstr += '</tr>';
		});
	} else if (strType == "withdrawPage") {// 提现记录
		$.each(json, function(i, v) {
			var amount=milliFormat(tomyToFixed(v.applyAmount+""));//截取小数点后两位 不用四舍五入
			if(i%2!=0){ 
			    htmlstr += '<tr bgcolor="#f5f5f5" >';
			}else{
				htmlstr += '<tr>';
			}
			htmlstr += '<td align="center">' + v.orderId + '</td>';
			if (v.applyTime != '' && v.applyTime != "null") {
				htmlstr += '<td align="center">' + v.applyTime+ '&nbsp;&nbsp;</td>';
			} else {
				htmlstr += '<td align="center">--</td>';
			}
			if (v.handleTime != '' && v.handleTime != "null") {
				htmlstr += '<td align="center">' + v.handleTime
						+ '&nbsp;&nbsp;</td>';
			} else {
				htmlstr += '<td align="center">--</td>';
			}
			htmlstr += '<td align="center">提现</td>';
			htmlstr += '<td align="center">支出</td>';
			if (v.dataName != null && v.dataName != "null") {
				htmlstr += '<td align="left"><span class="orange">-' +amount+ "</span>&nbsp;&nbsp;"+ v.dataName + '</td>';
			} else {
				htmlstr += '<td align="left">' + amount+ '&nbsp;&nbsp; --</td>';
			}
			htmlstr += get_withdrawStatus(v.status); // 提现状态判断
			htmlstr += '<td align="center">'+SearChwithRemark(trim(v.info).replace(/(\n)+|(\r\n)+/g, " "))+'</td>'; // 备注 去掉换行
			htmlstr += '</tr>';
		});
	} else if (strType == "qbEarningsPage") {// 钱包收益
		$.each(json, function(i, v) {
			if(i%2!=0){ 
			    htmlstr += '<tr bgcolor="#f5f5f5" >';
			}else{
				htmlstr += '<tr>';
			}			
			//var ty = parseInt(v.profit)>0 ? "+" : "-";
			htmlstr += '<td align="center">' + v.profitDate.substring(0, 10) + '</td>';
			htmlstr += '<td align="center" class="green">' + "+" + milliFormat(tomyToFixed(v.profit +"")) + '</td>';
			htmlstr += '<td align="center">' + (parseInt($("#daysInYear").val())*parseFloat(v.profitRate)).toFixed(2) + '</td>';
			htmlstr += '<td align="center">' + milliFormat(tomyToFixed(v.effectAmount +""))+ '</td>';
			htmlstr += '<td align="center">' + v.markInfo + '</td>';
			htmlstr += '</tr>';
		});
	} else if (strType == "hkbEarningsPage") {	//定期计划收益
		$.each(json, function(i, v) {
			if(i%2!=0){ 
			    htmlstr += '<tr bgcolor="#f5f5f5" >';
			}else{
				htmlstr += '<tr>';
			}
			htmlstr += '<td align="center">' + v.profitDate.substring(0, 10) + '</td>';
			htmlstr += '<td align="center">' + v.proTitle + '</td>';
			htmlstr += '<td align="center">' + v.orderId + '</td>';
			htmlstr += '<td align="center" class="green"> +' + v.profit.toFixed(2) + '</td>';
			htmlstr += '<td align="center">' + (parseInt($("#hkbDaysInYear").val())*parseFloat(v.profitRate)).toFixed(2) + '%</td>';
			htmlstr += '<td align="center">' + v.effectAmount.toFixed(2) + '</td>';
			htmlstr += '</tr>';
		});
	}
	return htmlstr;
}

function toShowDate(obj,formatStr){
	 var date = new Date();
	 date.setTime(obj.time);
	 date.setHours(obj.hours);
	 date.setMinutes(obj.minutes);
	 date.setSeconds(obj.seconds);
	 return date.format(formatStr); 
}

//时间显示
function showRecordTime(time){
//	var timeHtml="";
//	if(isnotEmpty(time)){
//		var t=time.split(" ");
//		for(var i=0;i<t.length;i++){
//			timeHtml+=t[i]+"";
//		}
//	}
	return time;
}

//资金记录金额金额+ -及不同颜色显示
function styleShowAmount(moneyType,amount,orderid){
	var styleAmount = "";
	var subtract="<td class='orange' align='center'>";
	var add="<td class='green' align='center'>";
	//var allNo="<td align='center'>";
	if(!isnotEmpty(amount)){//当金额为空时候 默认给0.00
		amount="0.00";
	}else{
		amount=milliFormat(amount);//金额国际化
	}
	if(moneyType<2000){//支出类
		styleAmount =subtract+"-"+amount;
	}else{//收入类
		styleAmount = add+"+"+amount;
		if(moneyType==2040||moneyType==2051||moneyType==2100||moneyType==2102){//2040惠信钱包-收益 2051惠卡宝收益 2100收益转入 2102奖励收入
			styleAmount = add+"+"+amount+"<a href='javascript:void(0)' title='点击查看详情' id='MoneyShow' name='"+moneyType+";"+orderid+"' class='arrow_icon'></a>";
		}
	}
	return styleAmount;
}

///支付类时候  商家具体店名称从OppositeTradeMapInfo字符截取
/*function getOtherPlatName(OppositeTradeMapInfo,oppositePlateformName){
	var OtherPlatName="";
	if(isnotEmpty(OppositeTradeMapInfo)){
		if(OppositeTradeMapInfo.indexOf(";")>-1){
			 var manyGoods=OppositeTradeMapInfo.split(";");
			 if(manyGoods.length>1){
				 OtherPlatName=oppositePlateformName;
				 return OtherPlatName;
			 }
		     for (var i = 0; i < manyGoods.length; i++) {
		    	 var propertys=manyGoods[i].split(":");
		    	 if(propertys.length>5){
		    		 OtherPlatName+=propertys[5]+";";
				 }
			 }
		     OtherPlatName=OtherPlatName.substring(0, OtherPlatName.length-1);
		}else{
			var propertys=OppositeTradeMapInfo.split(":");
			if(propertys.length>5){
				OtherPlatName=propertys[5];
			}
		}
	}
	if(isnotEmpty(OtherPlatName)){
		OtherPlatName=subStr(OtherPlatName,20);
	}else{
		OtherPlatName="--";
	}
	
	return OtherPlatName;
}*/
function getOtherPlatName(OppositeTradeMapInfo,oppositePlateformName){
	var OtherPlatName="";
	if(isnotEmpty(OppositeTradeMapInfo)){
		if(OppositeTradeMapInfo.indexOf("#qb,#")>-1){
			 var manyGoods=OppositeTradeMapInfo.split("#qb,#");
			 if(manyGoods.length>1){
				 OtherPlatName=oppositePlateformName;
				 return OtherPlatName;
			 }
		     for (var i = 0; i < manyGoods.length; i++) {
		    	 var propertys=manyGoods[i].split("#qb:#");
		    	 if(propertys.length>5){
		    		 OtherPlatName+=propertys[5]+";";
				 }
			 }
		     OtherPlatName=OtherPlatName.substring(0, OtherPlatName.length-1);
		}else{
			var propertys=OppositeTradeMapInfo.split("#qb:#");
			if(propertys.length>5){
				OtherPlatName=propertys[5];
			}
		}
	}
	if(isnotEmpty(OtherPlatName)){
		OtherPlatName=subStr(OtherPlatName,20);
	}else{
		OtherPlatName="--";
	}
	
	return OtherPlatName;
}

//根据不同交易类型 显示对方
function get_otherPlate(moneyType,oppositePlateformName,oppositeTradeName){
	var oppositeName = "";
	if(oppositePlateformName==''){//平台名称
		oppositePlateformName="惠信钱包";
	}
	if(oppositeTradeName==''){//具体商家店
		oppositeTradeName="--";
	}	
	switch (moneyType) {
		case 1010://支付 类 显示具体店名
			oppositeName = getOtherPlatName(oppositeTradeName,oppositePlateformName);
			break;
		case 2010://销售收入类 显示具体店名
			oppositeName = oppositeTradeName;
			break;
		default://其他显示平台名
			oppositeName =oppositePlateformName;
	}
	return oppositeName;
}

// 资金记录状态判断
function get_moneyRecordStatus(moneyRecordStatus,moneyType) {
	var statusStr = "";
	var htmlstr = "";
	moneyfrom = "";
	if(moneyType==2030){//充值
		if (moneyRecordStatus == 1) {
			statusStr = "充值成功";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 2) {
			statusStr = "处理中...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 3) {
			statusStr = "充值失败";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else{
			htmlstr += '<td align="center">--</td>';
		}
	}
	else if(moneyType==1100){//提现
		if (moneyRecordStatus == 1) {
			statusStr = "提现成功";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 2) {
			statusStr = "审核中...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 3) {
			statusStr = "转账中...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 4) {
			statusStr = "提现失败";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 5) {//在前台不显示有风险 同样显示 审核中
			statusStr = "审核中...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else{
			htmlstr += '<td align="center">--</td>';
		}
	}
	else{
		if (moneyRecordStatus == 1) {
			statusStr = "交易成功";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 2) {
			statusStr = "等待支付 ...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 3) {
			statusStr = "等待付款 ...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 4) {
			statusStr = "支付失败 ";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 11) {
			statusStr = "收款成功";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 12) {
			statusStr = "待收款...";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		} else if (moneyRecordStatus == 13) {
			statusStr = "退款";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else if (moneyRecordStatus == 14) {
			statusStr = "申请退款";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else if (moneyRecordStatus == 15) {
			statusStr = "退款成功";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else if (moneyRecordStatus == 16) {
			statusStr = "退款失败";
			htmlstr += '<td align="center">' + statusStr + '</td>';
		}else{
			htmlstr += '<td align="center">--</td>';
		} 
	}
	return htmlstr;
}

///支付类时候 商品名称从OppositeTradeMapInfo字符截取
function getGoodsName(OppositeTradeMapInfo,flage){
	var goodsName="";
	if(isnotEmpty(OppositeTradeMapInfo)){
		if(OppositeTradeMapInfo.indexOf("#qb,#")>-1){
			 var manyGoods=OppositeTradeMapInfo.split("#qb,#");
			 if(manyGoods.length>1 && manyGoods[1]!='' && flage=="get_moneyTypeName"){
				 goodsName="商品合并付款";
				 return goodsName;
			 }
		     for (var i = 0; i < manyGoods.length; i++) {
		    	 var propertys=manyGoods[i].split("#qb:#");
		    	 if(propertys.length>1){
		    		 goodsName+=propertys[1]+";";
		    	 }
			 }
		     goodsName=goodsName.substring(0, goodsName.length-1);
		}else{
			 if(flage=="getMangerGoods"){
				 return goodsName;
			 }
			var propertys=OppositeTradeMapInfo.split("#qb:#");
			if(propertys.length>1){
				goodsName=propertys[1];
			}
		}
	}
	if(isnotEmpty(goodsName)){
		goodsName=subStr(goodsName,20);
	}
	return goodsName;
}

//当有多个商品合并付款时候 悬浮提示多个商品名称
function getMangerGoods(orderid,moneyType,OppositeTradeMapInfo){
	var managerGoods="";
	switch (moneyType) {
	case 1010:
		var managerGoodsName=getGoodsName(OppositeTradeMapInfo,"getMangerGoods");
		if(isnotEmpty(managerGoodsName)){
			managerGoods=subStr("流水号为"+orderid+"包括以下商品:"+managerGoodsName,100)+"【详情点击查看】";
		}
		break;
	default:
	}
	return managerGoods;
}

//获得 收支记录里面的名称
function get_moneyTypeName(moneyType,info,oppositePlateformName,OppositeTradeMapInfo,remarkSomeinfo,moneyTypeCell,moneyTypeName,moneyTypeCellName) {//资金类型,商品描述,平台名称，支付类里面的商品名称
	if(!isnotEmpty(moneyTypeName)){
		moneyTypeName='--';
	}
	var moneyfrom = "";
	if(oppositePlateformName==''){//平台名称
		oppositePlateformName="惠信钱包";
	}
	switch (moneyType) {
		case 1010://支付类 显示平台-商品名称
			var goodsName=getGoodsName(OppositeTradeMapInfo,"get_moneyTypeName");//
			moneyfrom = oppositePlateformName+"-"+goodsName;
			if(!isnotEmpty(oppositePlateformName)||!isnotEmpty(goodsName)){
				moneyfrom=moneyfrom.replace("-","");
			}
			break;
		case 2010://销售收入类 显示平台-商品名称
			moneyfrom = oppositePlateformName+"-"+info;
			if(!isnotEmpty(oppositePlateformName)||!isnotEmpty(info)){
				moneyfrom=moneyfrom.replace("-","");
			}
			break;
		case 2051:
			moneyfrom="定期-收益";
			if(isnotEmpty(remarkSomeinfo)){
				moneyfrom = remarkSomeinfo;
			}
			break;
		case 2013:
			moneyfrom = oppositePlateformName+"-退款进账";
			break;
		case 2081:
			moneyfrom =oppositePlateformName+"-推广收入";
			break;
		case 2100:
			moneyfrom =oppositePlateformName+"-收益转入";
			break;
		default:
		    moneyfrom = moneyTypeName;
	}
	moneyfrom=get_moneyTypeCell(moneyfrom,oppositePlateformName,moneyTypeCellName);//显示二级交易类型
	return moneyfrom;
}

//显示二级资金交易类型
function get_moneyTypeCell(moneyType_Name,plateName,moneyTypeCellName){
	if(!isnotEmpty(moneyTypeCellName)){
		return moneyType_Name;
	}
	return plateName+moneyTypeCellName;//平台名称+二级交易类型显示名称
}

//资金记录钱包和惠卡宝收益点击金额显示 相关信息
jQuery(function($) {
	var $liveTip = $('<div id="livetip"></div>').hide().appendTo('body');
	var tipTitle = '';
	$('#moneyRecordPage_tab').bind('click mouseout mousemove', function(event) {
	  var $link = $(event.target).closest('#MoneyShow');
	  if (!$link.length) { return; }
	  var link = $link[0];
	
	  if (event.type =='click') {
		$liveTip.css({
		  top: event.pageY + 10,
		  left: event.pageX - 50
		});
	  };
	
	  if (event.type == 'click') {
		 tipTitle = link.name;
		 if(!isnotEmpty(tipTitle)){
			 return;
		 }
		 var type_orderid=tipTitle.split(";");
		 var type=type_orderid[0];
		 var orderid=type_orderid[1];
		// var ii = layer.load('加载中...');
		 var info="无数据";
		 $.ajax({
			type : "POST",
			url : "fundRecord_fundsMoneyRemark.action",
			data : {"mon.moneyType":type,"mon.orderId":orderid},
			dataType : 'json',
			success : function(data) {
				//layer.close(ii);
				if(data!=null&& data !=""){
					var date=data[0].profitDate.split(" ")[0];
					if(type==2040){
						info="该笔收益金额为"+date+"日钱包收益";
					}else if(type==2051){
						info="<p>该笔收益金额为"+date+"日收益</p>";
					}else if(type==2100 || type==2101 ){
						info="该笔收益金额为"+date+"日收益";
					}
				}
				$liveTip.html('<div class="arrow_moeny_top"></div><div class="abc">'+info+'</div>').show();
	            tipTitle='';
			}
		});
	  };
	
	  if (event.type == 'mouseout') {
			 $liveTip.hide();
				if (tipTitle) {
					link.title = tipTitle;
				};
	  };
	});
});

//----------------------------------------------------提现记录------------------------------------------
//提现状态判断
function get_withdrawStatus(withdrawStatus) {
	var statusStr = "";
	var htmlstr = "";
	if (withdrawStatus == 1) {
		statusStr = "成功";
		htmlstr += '<td align="center">' + statusStr + '</td>';
	} else if (withdrawStatus == 2) {
		statusStr = "审核中...";
		htmlstr += '<td align="center" class="green_lake">' + statusStr + '</td>';
	} else if (withdrawStatus == 3) {
		statusStr = "转账中...";
		htmlstr += '<td align="center" style="color:#00a0e9;">' + statusStr + '</td>';
	} else if (withdrawStatus == 4) {
		statusStr = "失败";
		htmlstr += '<td align="center" style="color:#f00;">' + statusStr + '</td>';
	} else if (withdrawStatus == 5) {//在前台不显示有风险 同样显示 审核中
		statusStr = "审核中...";
		htmlstr += '<td align="center" class="green_lake">' + statusStr + '</td>';
	}else{
		htmlstr += '<td align="center">--</td>';
	}
	return htmlstr;
}

// 去查看详情
function to_detail(moneyType,orderid,moneyTypeName,someInfoTwo) {
	if(moneyTypeName=="undefined"){
		moneyTypeName="";
	}
	if(someInfoTwo=="undefined"){
		someInfoTwo="";
	}
	location.href = "fundRecord_moneyRecordPageDetail.action?moneyType="+moneyType+"&mon.orderId="
			+ trim(orderid)+"&toDetailOtn="+someInfoTwo+"&toDetailMtname="+moneyTypeName;
}

//提现备注显示
function SearChwithRemark(info,id){
	var htmlinfo="--";
	if(isnotEmpty(info)){
		htmlinfo="<a href='javascript:void(0)' onclick='showReason(\""+info+"\")' class='blue' title='点击查看审核备注详情'>查看</a>";
	}
	return htmlinfo;
}

//提现备注显示
function showReason(info){
	   $.layer({
		   title : ['审核备注' , true],
		   area: ['450px', 'auto'],
		   dialog: {
			    btns : 0,
			    type: -1,
			    msg : info
			}
	   });
}

//------------------------------------------------充值记录显示----------------------------------------------------
//充值金额显示
function ShowRechargeMoney(money){
	var showmoeny="";
	if(isnotEmpty(money)){
	   if(money>0){
		   money=milliFormat(money);
		   showmoeny="<span class='green'>+"+money + "</span>";//充值金额大于0时候
	   }else{
		   showmoeny="<span>"+money + "</span>";//充值金额为负数 扣款
	   }
	}
	return showmoeny;
}

//充值类型
function isOnLinerecharge(type){
	var str="在线充值";
	if(type==5){
		str="后台充值";
	}
	return str;
}

//充值资金来源渠道
function get_moneyfrom(moenyfromType) {
	var moneyfrom = "";
	switch (moenyfromType) {
	case 1:
		moneyfrom = "银联";
		break;
	case 2:
		moneyfrom = "国付宝";
		break;
	case 3:
		moneyfrom = "汇潮支付";
		break;
	case 4:
		moneyfrom = "连连支付";
		break;
	case 5:
		moneyfrom = "系统充值";
		break;
	case 6:
		moneyfrom = "宝付支付";
		break;
	default:
		moneyfrom = "--";
	}
	return moneyfrom;
}

//充值状态判断
function get_RechargeRecordStatus(RechargeRecordStatus) {
	var statusStr = "";
	var htmlstr = "";
	if (RechargeRecordStatus == 1) {
		statusStr = "充值成功";
		htmlstr += '<td align="center" class="green">' + statusStr + '</td>';
	} else if (RechargeRecordStatus == 2) {
		statusStr = "处理中...";
		htmlstr += '<td align="center">' + statusStr + '</td>';
	} else if (RechargeRecordStatus == 3) {
		statusStr = "充值失败";
		htmlstr += '<td align="center">' + statusStr + '</td>';
	}else{
		htmlstr += '<td align="center">--</td>';
	}
	return htmlstr;
}
//---------------------------------------------------辅助-------------------------------------------------
function trim(str) { // 删除左右两端的空格
	return str.replace(/(^\s*)|(\s*$)/g, "");
}


//验证非空
function isnotEmpty(vals){
	var bool=false;
	if(vals!=""&&vals!="undefined"&&vals!=null&&vals.length>0){
		bool=true;
	}
	return bool;
}

//截取小数点后两位 不用四舍五入
function tomyToFixed(money){
	if(money.indexOf(".")<0){
		 money+=".00";
	 }
	 var newmoney="0.00";	
	 if(isnotEmpty(money)){
		 newmoney=(money.substring(0,money.indexOf(".")+3)*1).toFixed(2);
	 }
	 return newmoney;
}

//当字段太长时候 截取部分显示
function subStr(strinfo,lengths){
	var Deflength=lengths;//长度大于100 就开始截取 部分
	if(isnotEmpty(strinfo) && strinfo.length>Deflength){
		strinfo=strinfo.substring(0, Deflength)+"...";
	}
	return strinfo;
}

//金额国际化
function milliFormat(s){//添加千位符  
    if(/[^0-9\.]/.test(s)) return "invalid value";  
    s=s.replace(/^(\d*)$/,"$1.");  
    s=(s+"00").replace(/(\d*\.\d\d)\d*/,"$1");  
    s=s.replace(".",",");  
    var re=/(\d)(\d{3},)/;  
    while(re.test(s)){  
        s=s.replace(re,"$1,$2");  
    }  
    s=s.replace(/,(\d\d)$/,".$1");  
    return s.replace(/^\./,"0.");
}

//进来初始收支记录分页
function onloadfun()
{
	var indexI=0;
	 var strRem="moneyRecordPage";
	        if('<s:property value="froInQueryType"/>'==""||'<s:property value="froInQueryType"/>'=="moneyRecordPage"){//收支记录
	        }else if('<s:property value="froInQueryType"/>'=="withdrawPage"){//提现
	        	indexI=2;
	        	strRem="withdrawPage";
	        }else if('<s:property value="froInQueryType"/>'=="RechargeRecordPage"){//充值
	        	indexI=1;
	        	strRem="RechargeRecordPage";
	        }
			to_find(1,strRem);
			$('#tab li').removeClass('fli').eq(indexI).addClass('fli');
			$('#tab_con > div').removeClass('fdiv').eq(indexI).addClass('fdiv');
}

//钱包和 惠卡宝
function to_other(str_type){
	if(str_type=='qb'){
		location.href="account/userWalletAction_qbUserWalletManage.action";
	}else{
		location.href="account/aipPlanAction_findByUserAipPlan.action?profit=1";
	}
}

